
{template 'common/header'}
{php load()->func('tpl')}
<style type="text/css">
	.type-child{padding-left:55px;background:url('{MODULE_URL}template/image/bg_repno.gif') no-repeat -248px -550px;}
</style>
<ul class="nav nav-tabs">
	<li {if $op == 'post'}class="active"{/if}><a href="{php echo $this->createWebUrl('nav', array('op' => 'post'))}">添加菜单</a></li>
	<li {if $op == 'display'}class="active"{/if}><a href="{php echo $this->createWebUrl('nav', array('op' => 'display'))}">管理菜单</a></li>
	<li {if $op == 'style'}class="active"{/if}><a href="{php echo $this->createWebUrl('nav', array('op' => 'style'))}">模板选择</a></li>
</ul>
{if $op == 'post'}
<div class="main">
	<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
	<input type="hidden" name="parentid" value="{$parentid}" />
	<div class="panel panel-default">
	  <div class="panel-heading">
	    <h3 class="panel-title">详细设置</h3>
	  </div>
	  <div class="panel-body">
	  		<div class="form-group">
			    <label for="displayorder" class="col-sm-2 control-label">排序</label>
			    <div class="col-xs-2">
			      <input type="text" name="displayorder" id='displayorder' class="form-control" value="{$category['displayorder']}" placeholder="排序"/>
			    </div>
			</div>
			<div class="form-group">
			    <label for="school" class="col-sm-2 control-label">菜单名称</label>
			    <div class="col-xs-3">
			      <input type="text" name="title" class="form-control" value="{$category['title']}" id='title' placeholder="请输入菜单名称"/>
			    </div>
			</div>
			<div class="form-group">
			    <label for="school" class="col-sm-2 control-label">菜单链接</label>
			    <div class="col-xs-8">
			     <!--  <input type="text" name="url" class="form-control" value="{$category['url']}" id='url' placeholder="请输入菜单链接"/> -->
			     {php echo tpl_form_field_link('url',$category['url'])}
			    </div>
			</div>
			<div class="form-group">
			    <label for="title" class="col-sm-2 control-label">系统图标</label>
			    <div class="col-xs-10">
			      {php echo tpl_form_field_icon(icon,$category['icon'])}
	            <span class="help-block">导航的背景图标，系统提供丰富的图标ICON。</span>
			    </div>
			 </div>
			 <div class="form-group">
			    <label for="title" class="col-sm-2 control-label">背景颜色</label>
			    <div class="col-xs-10">
			      {php echo tpl_form_field_color(bgcolor,$category['bgcolor'])}
	              <span class="help-block">导航的背景颜色。</span>
			    </div>
			 </div>
			<div class="form-group">
			    <label for="" class="col-sm-2 control-label"></label>
			    <div class="col-sm-10">
			      <input name="submit" type="submit" value="提交" class="btn btn-primary span3">
					<input type="hidden" name="token" value="{$_W['token']}" />
			    </div>
			</div>
	  </div>
	</div>
	</form>
</div>
{elseif $op == 'display'}
<div class="main">
	<div class="category">
		<form action="" method="post" onsubmit="return formcheck(this)">
		<table class="table table-hover">
			<thead>
				<tr>
					<th style="width:10px;"></th>
					<th style="width:80px;">显示顺序</th>
					<th>菜单名称</th>
					<th style="width:40%;">操作</th>
				</tr>
			</thead>
			<tbody>
			{loop $list $row}
				
				<tr>
					<td>
						
						<a href="javascript:;">
							<i class="icon-chevron-down"></i>
						</a>
						
					</td>
					<td>
						<input type="text" class="form-control" name="displayorder[{$row['id']}]" value="{$row['displayorder']}">
					</td>
					<td>
						<div class="type-parent">{$row['title']}&nbsp;&nbsp;
							<a href="{php echo $this->createWebUrl('nav', array('pcate' => $row['id'], 'op' => 'post'))}">
								<i class="glyphicon glyphicon-plus-sign"></i> 添加菜单
							</a>&nbsp;&nbsp;&nbsp;
							
							
						</div>
					</td>
					<td>
						 <input type="checkbox" value="1"{if intval($row[status])==1} checked="checked"{/if} data="{$row[id]}"/>
					</td>
				</tr>
				
				{loop $children[$row['id']] $item}
				<tr>
					<td></td>
					<td><input type="text" class="form-control" name="displayorder[{$item['id']}]" value="{$item['displayorder']}"></td>
					<td>
						<div class="type-child">{$item['title']}&nbsp;&nbsp;
							
						</div>
					</td>
					<td>
						<a href="{php echo $this->createWebUrl('nav', array('op' => 'post', 'id'=>$item['id']))}" title="编辑" class="btn btn-default btn-sm"><i class="fa fa-edit" data-toggle="tooltip" data-placement="top"></i>
						
							<!-- <i class="glyphicon glyphicon-plus-sign"></i>编辑菜单 --></a>&nbsp;&nbsp;
						 <input type="checkbox" value="1"{if intval($item[status])==1} checked="checked"{/if} data="{$item[id]}"/>
					</td>
				</tr>
				{/loop}
			{/loop}
				<tr>
					<td></td>
					<td colspan="3">
						<input name="submit" type="submit" class="btn btn-primary" value="提交">
						<input type="hidden" name="token" value="{$_W['token']}" />
					</td>
				</tr>
			</tbody>
		</table>
		</form>
	</div>
	<div class="pull-right">{$pager}</div>
</div>
{elseif $op == 'style'}
<form action="" method="post" class="form-horizontal form" id="form1">
		<div class="panel panel-default">
			<div class="panel-heading">模板设置</div>
			<div class="panel-body">
				
				<div class="form-group clearfix">
					<label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">选择风格</label>
					<div class="clearfix">
						<div class="col-sm-4 col-lg-4 col-xs-12">
							<select name="styleid" class="form-control" id="styleid">
								<option value="0" {if $item['styleid'] == 0}selected='selected'{/if}>使用默认设置</option>
								<option value="1" {if $item['styleid'] == 1}selected='selected'{/if}>style1</option>
								
								<option value="3" {if $item['styleid'] == 3}selected='selected'{/if}>style3</option>
								<option value="4" {if $item['styleid'] == 4}selected='selected'{/if}>style4</option>
								<option value="5" {if $item['styleid'] == 5}selected='selected'{/if}>style5</option>
								
								<option value="10" {if $item['styleid'] == 10}selected='selected'{/if}>style10</option>
							</select>
						</div>
					</div>
					<!-- <div>
						<label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"></label>
						<div class="col-sm-8 col-xs-12">
							<span class="help-block">
								新建分类风格时，请在您选择的风格对应的模板目录下新建“site”文件夹，
								默认的列表页面为list.html，默认的内容页面为detail.html。
							</span>
						</div>
					</div> -->
				</div>


				<div class="form-group">
					<div class="col-sm-12" style="margin-left:70px;">
						<input name="submit" type="submit" value="提交" class="btn btn-primary col-lg-1">
						<input type="hidden" name="token" value="{$_W['token']}" />
					</div>
				</div>
			</div>
		</div>
</form>

{/if}
<script type="text/javascript">
	require(['bootstrap.switch', 'util'], function($, u){
        $(function(){
            $(':checkbox').bootstrapSwitch();
            $(':checkbox').on('switchChange.bootstrapSwitch', function(e, state){
                $this = $(this);
                var id = $this.attr('data');
                var status = this.checked ? 1 : 0;
                // alert(hid);return false;
                $.post(location.href, {status: status, id: id}, function(resp){
                    if(resp != 'success') {
                        u.message('操作失败, 请稍后重试.')
                    }
                    {if !empty($module)}
                    else {
                        u.message('操作成功！');
                        window.setTimeout(function(){location.href = location.href;}, 800);
                    }
                    {/if}
                });
            });
            $('.btn').hover(function(){
                $(this).tooltip('show');
            },function(){
                $(this).tooltip('hide');
            });
        });
    });
</script>
{template 'common/footer'}

